Dynomotion

Group: DynoMotion Message: 10679 From: rjreese29@ymail.com Date: 12/16/2014
Subject: Ending a thread on a timeout/mach reset
Hi,

I am using mach3 with a kflop. During a homing routine, either called by refall or one of the flags, I periodically encounter a situation where the thread just continues to run with no movement. This causes me to have to open kmotion to stop the thread. The cause of no
Motion during the homing process is no fault but my own, eg, axis not enabled. Other than that, the homing thread typically works.

What would be your recommendation in having the thread halt automatically? A time out would be ok, but A mach3 reset would seem ideal to halt the thread.
Any other thoughts are appreciated.
My experience in c is minimal at this point,

Thanks kindly,
Rob
Group: DynoMotion Message: 10681 From: Tom Kerekes Date: 12/17/2014
Subject: Re: Ending a thread on a timeout/mach reset
Hi Rob,

I suspect the Home program is hung up waiting to hit the limit switch, but because the axis is disabled and doesn't move this never happens.

One solution would be to add a check in each wait for limit switch loop to check if the axis is not enabled, and if so exit.  Something like in the SimpleHomeIndexFunction.c example:

    while (ReadBit(limitbit)!=limitpolarity) // loop until Limit bit goes to specified polarity
        if (!chan[axis].Enable) return 1;     // abort/exit if disabled

Alternatively you could add a line if C code to your Reset/Initialization to Kill the Home thread (assuming it runs in Thread #2):

   PauseThread(2);

HTH
Regards
TK



Group: DynoMotion Message: 10687 From: Rjreese29 Date: 12/17/2014
Subject: Re: Ending a thread on a timeout/mach reset
Hi Tom,
Thanks, pause thread is what I was looking for if it makes that green light on the thread turn off and exit the thread. I did try threaddone, but it didn't workout.

On your recommendation for the simpleindexhomefunction, I wasn't real clear in my description about what on my axis is enabled. The only time homing thread stays running is because my axis motor is not physically enabled with power, but within the kflop axis screen, it is always enabled as long as my init file is running. So this Might not apply

Much appreciated, I will give it a go and let you know.

Thanks

Rob

On Dec 17, 2014, at 8:46 AM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:

 

Hi Rob,

I suspect the Home program is hung up waiting to hit the limit switch, but because the axis is disabled and doesn't move this never happens.

One solution would be to add a check in each wait for limit switch loop to check if the axis is not enabled, and if so exit.  Something like in the SimpleHomeIndexFunction.c example:

    while (ReadBit(limitbit)!=limitpolarity) // loop until Limit bit goes to specified polarity
        if (!chan[axis].Enable) return 1;     // abort/exit if disabled

Alternatively you could add a line if C code to your Reset/Initialization to Kill the Home thread (assuming it runs in Thread #2):

   PauseThread(2);

HTH
Regards
TK